﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace AlbumDesigner.Helpers
{
    //this FilterAttribute checks if the request come from Flex (if not - ignore it)
    public class OnlyFlexAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            var referrer = filterContext.HttpContext.Request.UrlReferrer.AbsolutePath;

            //check that the referrer is the flex file
            if (!referrer.Contains("AlbumDesigner.swf"))
            {
                filterContext.Result = new ContentResult();
            }
        }
    }
}